import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { DomWarPointInfo } from "./DomWarPointInfo";
import { ObjCreate } from "../../common/ObjCreate";
import { TaskTargetInfo } from "../../../model/TaskTargetInfo";
import { MapFileUtil } from "../../../scene/map/MapFileUtil";
import { EntityType } from "../../../rules/EntityType";
import { AIManager } from "../../../scene/ai/AIManager";
import { AIType } from "../../../scene/ai/AIType";
import { Cache } from "../../../cache/Cache";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class DomWarPointCellRenderer
    
    export  class DomWarPointCellRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        /* internal  */get info(): DomWarPointInfo
        {
            return this._data as DomWarPointInfo;
        }

        protected /* override */ configUI(): void
        {
            super.configUI();
            this._pointTxt = ObjCreate.createGTextField("", 0, 0, 30, 25, this);
            this._pointTxt.mouseEnabled = false;
            this.buttonMode = true;
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onClick);
            return;
        }

        protected onClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=null;
            if (this.info && this.info.monsterPoint) 
            {
                loc1 = new TaskTargetInfo();
                loc1.mapId = MapFileUtil.mapID;
                loc1.x = this.info.monsterPoint.x;
                loc1.y = this.info.monsterPoint.y;
                loc1.targetType = EntityType.Point;
                AIManager.onAutoPathAIControl(loc1, AIType.AI_Scene);
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=false;
            if (arg1 == null) 
            {
                return;
            }
            super.data = arg1;
            if (this.info == null) 
            {
                return;
            }
            if (this.info.force != -1) 
            {
                loc1 = Cache.instance.role.entityInfo.force == this.info.force;
            }
            else 
            {
                loc1 = !Cache.instance.dominion.isHitTeam();
            }
            this.updateColor(loc1, this.info.isBossRefresh);
            return;
        }

        public updateColor(arg1: Boolean, arg2: Boolean): void
        {
            var loc1=null;
            var loc2=false;
            loc2 = !arg2;
            if (arg2) 
            {
                loc1 = GlobalStyle.color3;
                this.mouseChildren = loc2;
                this.mouseEnabled = loc2;
            }
            else 
            {
                this.mouseChildren = loc2;
                this.mouseEnabled = loc2;
                if (arg1) 
                {
                    loc1 = GlobalStyle.color5;
                }
                else 
                {
                    loc1 = GlobalStyle.color7;
                }
            }
            this._pointTxt.htmlText = "<u>" + HTMLUtil.addColor(this.info.nameTxt, loc1, "", 13) + "</u>";
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            super.dispose(arg1);
            this.removeEventListener(flash.events.MouseEvent.CLICK, this.onClick);
            return;
        }

        /* internal */ /* var */_pointTxt: GTextFiled;
    }
